﻿using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using DevExpress.XtraReports.UI;
using System.Data;

namespace QuanLyThuNgan
{
    public partial class rpt_CLS_DH : DevExpress.XtraReports.UI.XtraReport
    {
        public rpt_CLS_DH()
        {
            InitializeComponent();
        }
        public DataSet ds = new DataSet();
        public DataSet Dds
        {
            get { return ds; }
            set { ds = value; }
        }
      //  public string donvithu, sohs, hoten, tuoi, tongsotien, nglaphieu, ngthutien, ngayhin;
        private void rpt_CLS_DH_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
        {
            ds = this.DataSource as DataSet;
            xrNgay.Text = "Ngày: " + Uit.it_Date.CurrentDate("dd/MM/yyyy");
            xrshs.Text = cbarcode.Bar128(ds.Tables["ThongTinBL"].Rows[0]["sohs"].ToString());
            xrNgayGioIn.Text = "Giờ in: " + Uit.it_Date.CurrentDate("hh") + "h " + Uit.it_Date.CurrentDate("mm") + "'   " + xrNgay.Text;
           
                      
        }

        private void xrTTPhaiThu_PrintOnPage(object sender, PrintOnPageEventArgs e)
        {
            //int icls = ds.Tables["InBienLaiCLS"].Rows.Count;
            int ibn = ds.Tables["InBienLai"].Rows.Count;
            int kk = e.PageIndex;
            if (kk == e.PageCount - 1 && ibn == 0)
                xrTTPhaiThu.Visible = true;
            else
                xrTTPhaiThu.Visible = false;
        }

        private void xrTT02_PrintOnPage(object sender, PrintOnPageEventArgs e)
        {
            int ibn = ds.Tables["InBienLai"].Rows.Count;
            int kk = e.PageIndex;
            if (kk == e.PageCount - 1 && ibn == 0)
                xrTT02.Visible = true;
            else
                xrTT02.Visible = false;
        }

        private void xrTT01_PrintOnPage(object sender, PrintOnPageEventArgs e)
        {  //int icls = ds.Tables["InBienLaiCLS"].Rows.Count;
            int ibn = ds.Tables["InBienLai"].Rows.Count;
            int kk = e.PageIndex;
            if (kk == e.PageCount - 1 && ibn == 0)
                xrTT01.Visible = true;
            else
                xrTT01.Visible = false;
        }

        private void xrNguoilapPhieu_PrintOnPage(object sender, PrintOnPageEventArgs e)
        {
            int ibn = ds.Tables["InBienLai"].Rows.Count;
            int kk = e.PageIndex;
            if (kk == e.PageCount - 1 && ibn == 0)
                xrNguoilapPhieu.Visible = true;
            else
                xrNguoilapPhieu.Visible = false;
        }

        private void xrNgayGioIn_PrintOnPage(object sender, PrintOnPageEventArgs e)
        {
            int ibn = ds.Tables["InBienLai"].Rows.Count;
            int kk = e.PageIndex;
            if (kk == e.PageCount - 1 && ibn == 0)
                xrNgayGioIn.Visible = true;
            else
                xrNgayGioIn.Visible = false;
        }

        private void xrNguoithutien_PrintOnPage(object sender, PrintOnPageEventArgs e)
        {
            int ibn = ds.Tables["InBienLai"].Rows.Count;
            int kk = e.PageIndex;
            if (kk == e.PageCount - 1 && ibn == 0)
                xrNguoithutien.Visible = true;
            else
                xrNguoithutien.Visible = false;
        }

        private void xrNguoithutien__PrintOnPage(object sender, PrintOnPageEventArgs e)
        {
            int ibn = ds.Tables["InBienLai"].Rows.Count;
            int kk = e.PageIndex;
            if (kk == e.PageCount - 1 && ibn == 0)
                xrNguoithutien_.Visible = false;
            else
                xrNguoithutien_.Visible = true;
        }

        private void xrNgayGioIn__PrintOnPage(object sender, PrintOnPageEventArgs e)
        {
            int ibn = ds.Tables["InBienLai"].Rows.Count;
            int kk = e.PageIndex;
            if (kk == e.PageCount - 1 && ibn == 0)
                xrNgayGioIn_.Visible = false;
            else
                xrNgayGioIn_.Visible = true;
        }

        private void xrNguoilapPhieu__PrintOnPage(object sender, PrintOnPageEventArgs e)
        {
            int ibn = ds.Tables["InBienLai"].Rows.Count;
            int kk = e.PageIndex;
            if (kk == e.PageCount - 1 && ibn == 0)
                xrNguoilapPhieu_.Visible = false;
            else
                xrNguoilapPhieu_.Visible = true;
        }

        private void GroupFooter2_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
        {
            //string sobn = GetCurrentColumnValue("sttmst").ToString();
            //if(sobn=="2")
            //GroupFooter2.PageBreak = DevExpress.XtraReports.UI.PageBreak.AfterBand;
            //else
       
        }

        private void Detail_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
        {
            //string cid = GetCurrentColumnValue("sobn").ToString();
            //string nextCid = GetNextColumnValue("sobn").ToString();

            //if (cid != nextCid)
            //    xrPageBreak1.Visible = true;
            //else
            //    xrPageBreak1.Visible = false;
        }

    }
}
